package com.example.anyong17_julnumgi;




import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.LinearLayout;
import com.google.ads.*;
import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;


public class MainActivity extends Activity {
		private static final String MY_AD_UNIT_ID = "a15244ebf863549";
		private AdView adView;



				AnimationDrawable mAni;
				int char_sel=1;
				@Override
                protected void onCreate(Bundle savedInstanceState) {
                        super.onCreate(savedInstanceState);
                        setContentView(R.layout.activity_main);
                        
                        LinearLayout layout = (LinearLayout)findViewById(R.id.LinearLayout1);
                        adView =new AdView(this,AdSize.BANNER, MY_AD_UNIT_ID); 
                        layout.addView(adView);
                        adView.loadAd(new AdRequest());  
                        
                        AdRequest adRequest = new AdRequest();//
                        adRequest.addTestDevice(AdRequest.TEST_EMULATOR);//
                        adView.loadAd(adRequest);  
                        
                        SharedPreferences pref = getSharedPreferences("JUL", 0);//sensor설정
                        char_sel=pref.getInt("cal_selec", 1);
                        
                        ImageView img = (ImageView) findViewById(R.id.main_img);
                        
                        /*if(char_sel<=1)img.setBackgroundResource(R.drawable.rabit);
                        if(char_sel==2)img.setBackgroundResource(R.drawable.tutle);
                        if(char_sel==3)img.setBackgroundResource(R.drawable.rion);
                        if(char_sel==4)img.setBackgroundResource(R.drawable.man);
                        if(char_sel==5)img.setBackgroundResource(R.drawable.army);
                        if(char_sel==6)img.setBackgroundResource(R.drawable.suq);
                        if(char_sel==7)img.setBackgroundResource(R.drawable.dars);
                        if(char_sel==8)img.setBackgroundResource(R.drawable.enter);*/
                        
                        img.setBackgroundResource(R.drawable.main_ani);
                        mAni=(AnimationDrawable)img.getBackground();
                        

                        
                        img.post(new Runnable() {
							
							@Override
							public void run() {
								mAni.start();
								
							}
						});
                        
                
                }
                public void mOnClick(View v){
                        switch(v.getId()){
                                
                                case R.id.main_start :
                                        startActivity(new Intent(this, MenuActivity.class));
                                        break;
                
                                
                                        
                        }
                }
                
                @Override
                protected void onResume() {
                // TODO Auto-generated method stub
                super.onResume();
                	mAni.stop();
                }
                @Override
                protected void onRestart() {
                super.onRestart();
                finish();
                }
                @Override
                protected void onDestroy() {
                	adView.destroy();    
                	RecycleUtils.recursiveRecycle(getWindow().getDecorView());
                	 System.gc();
                	 super.onDestroy();
                }
}